/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Affichage;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JToggleButton;

import AccesAuxDonnees.*; //TODO : virer (pour test)
import Metier.*;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 * @pdOid a2170e4b-8e01-4799-97f2-60ddf44bc317
 */
public class Affichage extends JFrame implements ActionListener {

    private JToggleButton btnMode;
    private JButton btnRecherche;
    private JButton btnAjouter;
    private JButton btnModifier;
    private JButton btnSupprimer;
    private JTextField champRechercher;
    private String chaineArechercher;
    public Ajouter ajouter;
    public Modifier modifier;
    public Supprimer supprimer;
    private final JButton BTNChangerMap;
    private final JToggleButton BTNConsultation;
    private final JToggleButton BTNGestion;
    private final JButton BTNPrecedent;
    private final JButton BTNRechercher;
    private final JButton BTNSuivant;
    private final JLabel LBLCoordonee;
    private final JLabel LBLGererLieu;
    private final JLabel LBLGererParcours;
    private final javax.swing.JLabel LBLHistorique;
    private final javax.swing.JLabel LBLNSur5;
    private final javax.swing.JLabel LBLSur5;
    private final javax.swing.JLabel LBLTXTX;
    private final javax.swing.JLabel LBLTXTY;
    private final javax.swing.JLabel LBLX;
    private final javax.swing.JLabel LBLY;
    private final javax.swing.JList LSTResultatRecherche;
    private static CustomPanel PanelCarte;
    private final javax.swing.JPanel PanelCoordonnee;
    private final javax.swing.JPanel PanelHistorique;
    private final javax.swing.JPanel PanelRecherche;
    private final javax.swing.JTextField TBXRechercher;
    private final javax.swing.JList jList1;
    private final javax.swing.JScrollPane jScrollPane1;
    private final javax.swing.JScrollPane jScrollPane2;
    private final javax.swing.JSeparator jSeparator1;
    private static Lieu lieu;
    private Dialogue dialog;
    private MouseListener carte_listener;
    private MouseListener poi_listener;
    private Vector<String> v;
    public News news;
    private final JLabel LBLTXTNOM;
    private final JLabel LBLNOM;
    private List<Lieu> listeDeLieus;
    public NewsAffichage newsAffichage;

    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        System.out.println("reerefefefe");
        if (source == BTNRechercher) {

            System.out.println("Chaine de caractères à rechercher : " + TBXRechercher.getText());

            Dialogue dialogue = new Dialogue();
            Vector monVecteurAffichage = new Vector();
            listeDeLieus = dialogue.rechercheLieu(TBXRechercher.getText());
            
            for(Descriptable d : listeDeLieus){
                monVecteurAffichage.add(d.getLibelle());
            }
            
            LSTResultatRecherche.setListData(monVecteurAffichage);

        }
        //    LSTResultatRecherche
        //   }
    }

    ;
   
   /** @pdOid ff3a4a5a-0ae8-46ec-a245-dbe0807fefa3 */
   public void affichage() {
        //Crée la fenêtre
        JFrame fenetre = new JFrame("miniSIG");
        //Détache la fenêtre du coin en haut à gauche.
        fenetre.setLocationRelativeTo(null);
        //Permet de killer le processus quand on ferme la fen�tre
        fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Container pannel = fenetre.getContentPane();

        pannel.setLayout(new GridLayout(3, 2));
        //  pannel.setLayout(new BoxLayout(fenetre.getContentPane(), BoxLayout.Y_AXIS));

        champRechercher = new JTextField();
        fenetre.add(champRechercher);

        btnRecherche = new JButton("Rechercher");

        btnRecherche.addActionListener(this);
        fenetre.add(btnRecherche);

        System.out.println(chaineArechercher);

        fenetre.pack();
        fenetre.setVisible(true);
    }


    /**
     * @pdOid 68b6efdc-7dec-4a39-bbf5-3b2bca25e898
     */
    public void afficherPopUpAjouter() {
        // TODO: implement
    }

    /**
     * @pdOid f2b93fe1-023d-4b80-a75a-ed190439e6f6
     */
    public void afficherPopUpSupprimer() {
        // TODO: implement
    }

    /**
     * @pdOid 82cf2cf4-03e9-4fd2-889f-7898ccd086af
     */
    public void afficherPopUpModifier() {
        // TODO: implement
    }

    public Affichage() throws IOException {
        news = new News();
        /*if(!news.getList() != null){
         news.afficher(); 
         }*/
        dialog = new Dialogue();
        // PanelCarte = new CustomPanel("SummonersRift.png");
        PanelCarte = new CustomPanel("carteFrance.png");
//        PanelCarte = new CustomPanel("F:\\A2ProjetJava\\projetJava2clone\\mini-sig-java\\MiniSig\\SummonersRift.png");
        //PanelCarte = new CustomPanel("C:\\Users\\utilisateur\\Google Drive\\Cours Exia\\PROJET\\A2\\Java\\Programme\\mini-sig-java\\MiniSig\\src\\SummonersRift.png");
        BTNConsultation = new javax.swing.JToggleButton();
        BTNGestion = new javax.swing.JToggleButton();
        PanelRecherche = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        LSTResultatRecherche = new javax.swing.JList();
        TBXRechercher = new javax.swing.JTextField();
        BTNRechercher = new javax.swing.JButton();
        PanelHistorique = new javax.swing.JPanel();
        LBLHistorique = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane2 = new javax.swing.JScrollPane();
        v = new Vector<String>();
        jList1 = new javax.swing.JList<String>(v);
        BTNPrecedent = new javax.swing.JButton();
        LBLSur5 = new javax.swing.JLabel();
        BTNSuivant = new javax.swing.JButton();
        LBLNSur5 = new javax.swing.JLabel();
        PanelCoordonnee = new javax.swing.JPanel();
        LBLCoordonee = new javax.swing.JLabel();
        LBLTXTX = new javax.swing.JLabel();
        LBLX = new javax.swing.JLabel();
        LBLTXTY = new javax.swing.JLabel();
        LBLY = new javax.swing.JLabel();
        LBLTXTNOM = new javax.swing.JLabel();
        LBLNOM = new javax.swing.JLabel();
        BTNChangerMap = new javax.swing.JButton();
        LBLGererLieu = new javax.swing.JLabel();
        LBLGererParcours = new javax.swing.JLabel();
        lieu = dialog.getLieu("FRANCE");
        dialog.getPOISLieu(lieu);
        carte_listener = new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {
                dialog.CreationNouveauPoint(e);
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        };

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(0, 0));
        setPreferredSize(new java.awt.Dimension(900, 660));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        PanelCarte.setBackground(new java.awt.Color(255, 255, 255));
        PanelCarte.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        PanelCarte.setPreferredSize(new java.awt.Dimension(700, 600));

        javax.swing.GroupLayout PanelCarteLayout = new javax.swing.GroupLayout(PanelCarte);
        PanelCarte.setLayout(PanelCarteLayout);
        PanelCarteLayout.setHorizontalGroup(
                PanelCarteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 700, Short.MAX_VALUE));
        PanelCarteLayout.setVerticalGroup(
                PanelCarteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 600, Short.MAX_VALUE));

        getContentPane().add(PanelCarte, new org.netbeans.lib.awtextra.AbsoluteConstraints(252, 56, 624, 525));

        BTNConsultation.setBackground(new java.awt.Color(153, 153, 153));
        BTNConsultation.setText("Consultation");
        BTNConsultation.setPreferredSize(new java.awt.Dimension(93, 23));
        getContentPane().add(BTNConsultation, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 120, 40));

        BTNGestion.setBackground(new java.awt.Color(153, 153, 153));
        BTNGestion.setText("Gestion");
        BTNGestion.setBorder(null);
        BTNGestion.setBorderPainted(false);
        BTNGestion.setPreferredSize(new java.awt.Dimension(33, 15));
        getContentPane().add(BTNGestion, new org.netbeans.lib.awtextra.AbsoluteConstraints(126, 10, 120, 40));

        PanelRecherche.setBackground(new java.awt.Color(255, 255, 255));
        PanelRecherche.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        LSTResultatRecherche.setModel(new javax.swing.AbstractListModel() {
            String[] strings = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};
        
        
            @Override
            public int getSize() {
                return strings.length;
            }

            @Override
            public Object getElementAt(int i) {
                return strings[i];
            }
        });
        
        LSTResultatRecherche.addListSelectionListener(new ListSelectionListener(){

            @Override
            public void valueChanged(ListSelectionEvent e) {
                int indexSelectionne = LSTResultatRecherche.getSelectedIndex();
                String carteAafficher = listeDeLieus.get(indexSelectionne).getCarte();
                CustomPanel carte = Affichage.getCarte();
                try {
                    carte.changeMap(carteAafficher);
                } catch (IOException ex) {
                    Logger.getLogger(Affichage.class.getName()).log(Level.SEVERE, null, ex);
                }
                lieu = dialog.getLieu(listeDeLieus.get(indexSelectionne).getLibelle());
                Afficher_Mode_Consultation();
                
            }

        });
        
        LSTResultatRecherche.setSelectionBackground(new java.awt.Color(153, 102, 255));
        jScrollPane1.setViewportView(LSTResultatRecherche);

        TBXRechercher.setForeground(new java.awt.Color(102, 102, 102));
        TBXRechercher.setText("Rechercher");
        TBXRechercher.setSelectionColor(new java.awt.Color(153, 102, 255));

        BTNRechercher.setIcon(new javax.swing.ImageIcon("search.jpg")); // NOI18N
        BTNRechercher.addActionListener(this);

        javax.swing.GroupLayout PanelRechercheLayout = new javax.swing.GroupLayout(PanelRecherche);
        PanelRecherche.setLayout(PanelRechercheLayout);
        PanelRechercheLayout.setHorizontalGroup(
                PanelRechercheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelRechercheLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelRechercheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelRechercheLayout.createSequentialGroup()
                .addComponent(TBXRechercher, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BTNRechercher, javax.swing.GroupLayout.PREFERRED_SIZE, 40, Short.MAX_VALUE))
                .addComponent(jScrollPane1))
                .addContainerGap()));
        PanelRechercheLayout.setVerticalGroup(
                PanelRechercheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelRechercheLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelRechercheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(TBXRechercher, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(BTNRechercher, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                .addContainerGap()));

        getContentPane().add(PanelRecherche, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 56, 236, -1));

        PanelHistorique.setBackground(new java.awt.Color(255, 255, 255));
        PanelHistorique.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        LBLHistorique.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        LBLHistorique.setText("Historique");
/*
        List<String> histo = dialog.getHistorique();
        if (!histo.isEmpty()) {
            for (String ligne : histo) {
                String[] ligne_format = ligne.split("/");
                String[] chaine_nom = ligne_format[0].split(":");
               String nom = chaine_nom[1];
                v.add(nom);
            }
            jList1.setListData(v);
        }
*/
        jScrollPane2.setViewportView(jList1);

        BTNPrecedent.setText("Précédent");

        BTNSuivant.setText("Suivant");

        BTNPrecedent.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (jList1.getSelectedIndex() > 0) {
                    System.out.println(jList1.getSelectedIndex() + "précédent");
                    jList1.setSelectedIndex(jList1.getSelectedIndex() - 1);
                } else {
                    System.out.println(jList1.getSelectedIndex() + "minimum selected");
                    jList1.setSelectedIndex(0);
                }
            }
        });
        BTNSuivant.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (v.size() > jList1.getSelectedIndex()) {
                    System.out.println(jList1.getSelectedIndex() + "suivant");
                    jList1.setSelectedIndex(jList1.getSelectedIndex() + 1);
                } else {
                    System.out.println(jList1.getSelectedIndex() + "max selected");
                    jList1.setSelectedIndex(v.size());
                }
            }
        });

        javax.swing.GroupLayout PanelHistoriqueLayout = new javax.swing.GroupLayout(PanelHistorique);
        PanelHistorique.setLayout(PanelHistoriqueLayout);
        PanelHistoriqueLayout.setHorizontalGroup(
                PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelHistoriqueLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelHistoriqueLayout.createSequentialGroup()
                .addComponent(LBLHistorique)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1))
                .addGroup(PanelHistoriqueLayout.createSequentialGroup()
                .addGroup(PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelHistoriqueLayout.createSequentialGroup()
                .addComponent(BTNPrecedent)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBLNSur5, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBLSur5)
                .addGap(18, 18, 18)
                .addComponent(BTNSuivant))
                .addComponent(jScrollPane2))
                .addContainerGap()))));
        PanelHistoriqueLayout.setVerticalGroup(
                PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelHistoriqueLayout.createSequentialGroup()
                .addGroup(PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(LBLHistorique)
                .addGroup(PanelHistoriqueLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PanelHistoriqueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(BTNPrecedent)
                .addComponent(LBLSur5)
                .addComponent(BTNSuivant)
                .addComponent(LBLNSur5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap()));

        getContentPane().add(PanelHistorique, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 365, 236, -1));

        PanelCoordonnee.setBackground(new java.awt.Color(255, 255, 255));
        PanelCoordonnee.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        LBLCoordonee.setBackground(new java.awt.Color(204, 204, 204));
        LBLCoordonee.setText("Coordonnées");
        BTNConsultation.setSelected(true);
        BTNConsultation.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (BTNConsultation.getModel().isSelected()) {
                    BTNGestion.setSelected(false);
                } else {
                    BTNGestion.setSelected(true);
                }
                Afficher_Mode_Consultation();
            }
        });
        BTNGestion.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (BTNGestion.getModel().isSelected()) {
                    BTNConsultation.setSelected(false);
                } else {
                    BTNConsultation.setSelected(true);
                }
                Afficher_Mode_Edition();
            }
        });
        LBLTXTX.setText("X : ");

        LBLX.setText("     ");

        LBLTXTY.setText("Y : ");

        LBLY.setText("     ");

        javax.swing.GroupLayout PanelCoordonneeLayout = new javax.swing.GroupLayout(PanelCoordonnee);
        PanelCoordonnee.setLayout(PanelCoordonneeLayout);
        PanelCoordonneeLayout.setHorizontalGroup(
                PanelCoordonneeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelCoordonneeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LBLCoordonee, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBLTXTX)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBLX)
                .addGap(18, 18, 18)
                .addComponent(LBLTXTY)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBLY)
                .addContainerGap(667, Short.MAX_VALUE)));
        PanelCoordonneeLayout.setVerticalGroup(
                PanelCoordonneeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelCoordonneeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(LBLCoordonee, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addComponent(LBLTXTX)
                .addComponent(LBLX)
                .addComponent(LBLTXTY)
                .addComponent(LBLY)));

        getContentPane().add(PanelCoordonnee, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 587, 866, -1));

        BTNChangerMap.setBackground(new java.awt.Color(255, 255, 255));
        BTNChangerMap.setIcon(new javax.swing.ImageIcon("Change_Map.jpg")); // NOI18N
        BTNChangerMap.setText("Changer de carte");
        BTNChangerMap.setEnabled(true);
        getContentPane().add(BTNChangerMap, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 10, 160, 40));
        BTNChangerMap.getAccessibleContext().setAccessibleName("BTNChangerMap");

        LBLGererLieu.setFont(new java.awt.Font("Minion Pro", 1, 18)); // NOI18N
        LBLGererLieu.setForeground(new java.awt.Color(153, 153, 153));
        LBLGererLieu.setText("Gérer les lieux");
        getContentPane().add(LBLGererLieu, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 20, -1, -1));
        LBLGererLieu.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent me) {
                GestionLieux Gerer = new GestionLieux();
                Gerer.setVisible(true);
                Gerer.setDefaultCloseOperation((JFrame.DISPOSE_ON_CLOSE));
            }
        });

        LBLGererParcours.setFont(new java.awt.Font("Minion Pro", 1, 18)); // NOI18N
        LBLGererParcours.setForeground(new java.awt.Color(153, 153, 153));
        LBLGererParcours.setText("Gérer les parcours");
        getContentPane().add(LBLGererParcours, new org.netbeans.lib.awtextra.AbsoluteConstraints(415, 20, -1, -1));
        LBLGererParcours.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent me) {
                GestionParcours GestParcours = null;
                try {
                    GestParcours = new GestionParcours();
                } catch (IOException ex) {
                    Logger.getLogger(Affichage.class.getName()).log(Level.SEVERE, null, ex);
                }
                GestParcours.setVisible(true);
                GestParcours.setDefaultCloseOperation((JFrame.DISPOSE_ON_CLOSE));
            }
        });

        PanelCarte.addMouseMotionListener(
                new MouseMotionListener() {
            @Override
            public void mouseDragged(MouseEvent e) {
            }

            @Override
            public void mouseMoved(MouseEvent e) {
                LBLX.setText(String.valueOf(e.getX()));
                LBLY.setText(String.valueOf(e.getY()));
            }
        });
        this.setVisible(
                true);
        this.setSize(
                900, 660);
        BTNChangerMap.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    ChangerLieu change = new ChangerLieu();
                    change.setVisible(true);
                    change.setDefaultCloseOperation((JFrame.DISPOSE_ON_CLOSE));
                } catch (IOException ex) {
                    Logger.getLogger(Affichage.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    public static CustomPanel getCarte() {
        return PanelCarte;
    }

    public static Lieu getLieu() {
        return lieu;
    }

    /**
     * @pdOid 68b6efdc-7dec-4a39-bbf5-3b2bca25e898
     */
    public void Afficher_Mode_Consultation() {
        for (POI poi : lieu.getList_POI()) {
            PanelCarte.remove(poi);
            for (MouseListener listen : poi.getMouseListeners()) {
                poi.removeMouseListener(listen);
            }
        }
        Afficher_POI_Consultation();
        LBLGererLieu.setVisible(false);
        LBLGererParcours.setVisible(false);
        PanelCarte.removeMouseListener(carte_listener);
    }

    /**
     * @pdOid f2b93fe1-023d-4b80-a75a-ed190439e6f6
     */
    public void Afficher_Mode_Edition() {
        for (POI poi : lieu.getList_POI()) {
            PanelCarte.remove(poi);
            for (MouseListener listen : poi.getMouseListeners()) {
                poi.removeMouseListener(listen);
            }
        }
        Afficher_POI_Edition();
        LBLGererLieu.setVisible(true);
        LBLGererParcours.setVisible(true);
        PanelCarte.addMouseListener(carte_listener);
    }

    public void Afficher_POI_Edition() {
        for (final POI poi : lieu.getList_POI()) {
            if (poi != null) {
                poi.setBounds(10, 10, 10, 10);
                poi.setLocation(poi.getX(), poi.getY());
                PanelCarte.setLayout(null);
                PanelCarte.add(poi);
                poi.addMouseListener(new MouseListener() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        Modifier modifier = null;
                        try {
                            modifier = new Modifier();
                        } catch (IOException ex) {
                        }
//                        dialog.getDesCriptifLienByPOI(poi);
                        modifier.Afficher_Modifier_POI(poi);
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                    }

                    @Override
                    public void mouseEntered(MouseEvent e) {
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                    }
                });
            }
        }
    }

    public void Afficher_POI_Consultation() {
        for (final POI poi : lieu.getList_POI()) {
            if (poi != null) {
                poi.setBounds(10, 10, 10, 10);
                poi.setLocation(poi.getX(), poi.getY());
                PanelCarte.setLayout(null);
                PanelCarte.add(poi);
                poi.addMouseListener(new MouseListener() {
                    @Override
                    public void mouseClicked(MouseEvent e) {

                        Description description = null;
                        try {
                            description = new Description();
                        } catch (IOException ex) {
                        }
                        //  dialog.getDesCriptifLienByPOI(poi);
                        //  description.Afficher_Description(poi);

                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                    }

                    @Override
                    public void mouseEntered(MouseEvent e) {
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                    }
                });
            }
        }
    }
}
